using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace QuanLyThuPhiTaiLieu.Entity
{
    [Table("PhieuBanGiaoTaiLieuChiTiet")]
    public class PhieuBanGiaoTaiLieuChiTiet
    {   
        public int Id { get; set; }

        [Column("PhieuBanGiaoId")]
        public int PhieuBanGiao { get; set; }        
       
        public string MaTaiLieu { get; set; }
       
        public string NoiDungYeuCau { get; set; }
        
        public int SoLuong { get; set; }
        
        public decimal DonGia { get; set; }
        
        public decimal ThanhTien { get; set; }
                
        public string TenTaiLieu { get; set; }
        
        public string LoaiTaiLieu { get; set; }
        public string DangTaiLieu { get; set; }

        public string DonViTinh { get; set; }
        public string Khlt { get; set; }
        public string TenBaoCao { get; set; }
        public string MaBaoCao { get; set; }
        public string MucThu { get; set; }

        [NotMapped]
        public string GroupValue
        {
            get
            {                
                return string.Format("{0} - {1}", Khlt, TenBaoCao);
            }
        }

        [NotMapped]
        public string MaTaiLieuValue
        {
            get
            {
                if (!string.IsNullOrEmpty(MaTaiLieu) && MaTaiLieu.LastIndexOf('.') > -1)
                {
                    return MaTaiLieu.Substring(0, MaTaiLieu.LastIndexOf('.') - 1);
                }

                return string.Empty;
            }
        }

        [NotMapped]
        public int MaTaiLieuIndexValue
        {
            get
            {
                if (!string.IsNullOrEmpty(MaTaiLieu) && MaTaiLieu.LastIndexOf('.') > -1)
                {                    
                    var indexValue = MaTaiLieu.Substring(MaTaiLieu.LastIndexOf('.') + 1);
                    int index = 0;
                    if (int.TryParse(indexValue, out index))
                    {
                        return index;
                    }
                }

                return 0;
            }
        }
    }

    [NotMapped]
    public class ThongKeTaiLieuCungCap
    {
        public int Id { get; set; }

        public int PhieuBanGiao { get; set; }

        public string MaTaiLieu { get; set; }

        public string NoiDungYeuCau { get; set; }

        public int SoLuong { get; set; }

        public decimal DonGia { get; set; }

        public decimal ThanhTien { get; set; }

        public string TenTaiLieu { get; set; }

        public string LoaiTaiLieu { get; set; }
        public string DangTaiLieu { get; set; }

        public string DonViTinh { get; set; }

        public string NguoiNhan { get; set; }
        public string DonVi { get; set; }
        public int? Nam { get; set; }
    }
}
